<table class="edit_table">
<%= form_for [:admins, @clue], :html => { :class => "form-horizontal notify" ,:onsubmit => "return check()"} do |f| %>
      
      <tr>
      <td>平台推送:</td>
      <td>
        <%i=0
          arr = [0,0,0]

          if params[:groups]
            p 1312312,params[:groups]
            params[:groups].each do |g|
              if g=='15'
                arr[0]=15
              end
              if g=='18'
                arr[1]=18
              end
              if g=='23'
                arr[2]=23
              end
            end
          end
          p 1312312,arr
        %>

        <% @groups.each do |group| %>
            <% if @clue.groups.collect(&:id).include?(group.id) %>
                <input type="checkbox" name="groups[]" value="<%= group.id %>" checked />
            <% else %>
                <input type="checkbox" name="groups[]" value="<%= group.id %>" <%=(arr[i] == group.id ? "checked":"")%> />
            <% end %>
            <%= group.platform_name %>
            <%i+=1%>
        <% end %>
        (<%= must_label %>送审之后将不能再修改)

      </td>
    </tr>
      
      <tr>
        <td>推送单位</td>
        <td>
         
        
         <% if @clue.contribution_units || !current_user.department %>
	        <%= f.select :contribution_units , @departments.collect{|dep| [dep.name,dep.name]} %> *
	    <% else %>
	        <%= f.select :contribution_units , @departments.collect{|dep| [dep.name,dep.name]}, :selected => current_user.department.name %> *
	    <% end %>
    
        </td>
      </tr>
      <tr>
        <td>联系人</td>
        <td>
          <%= f.text_field :linkman,:class => 'long_input',required:true %> *
        </td>
      </tr>
      <tr>
        <td>联系电话</td>
        <td>
          <%= f.text_field :phone,required:true %> *
        </td>
      </tr>
      <tr>
        <td>线索内容</td>
        <td>
          <%= f.text_area :content,:size => "80x10",required:true %> *
        </td>
      </tr>
      <tr>
        <td colspan="2" align="center">
          <%= f.submit'确认',:class => 'btn btn-primary',:onclick => "getKind();" %>
          <%= link_to '返回',admins_clues_path,:class => 'btn btn-info' %>
        </td>
      </tr>
<% end %>
</table>

<script type="text/javascript">
  var getKind = function getKind(){
      $("#sec_value").val($("#sec_cate_id").val());
   
  }
  function check(){				
				var ids = document.getElementsByName("groups[]");				
				var flag = false ;				
				for(var i=0;i<ids.length;i++){
					if(ids[i].checked){
						flag = true ;
						break ;
					}
				}
				if(!flag){
					alert("请最少选择一平台推送！");
					return false ;
				}
			}
  $(document).ready(getKind);
  $(document).on('page:load', getKind);
</script>

